<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui" 
      >
<h:body>
<ui:composition template="/pages/template.xhtml">
        <ui:define name="conteudo">
           <!-- Div para cadastro de usuario no sistema -->
           <div id="cadastroUsuario">
                   <h:form id="cadastrarUsuario_form">
                     <p:panel header="Cadastro de usuario">        
                           <p:messages id="message_cadastrar" />
                           <h:panelGrid columns="3" id="cadastrar">
                                   <p:outputLabel value="Nome" for="nome"/>
                                   <p:inputText value="#{usuarioBean.usuario.nome}" id="nome" required="true" requiredMessage="Nome Obrigatorio">
                                   </p:inputText>  
                                   <h:outputText>&nbsp;</h:outputText>
                                   
                                   <p:outputLabel value="Email" for="email"/>
                                   <p:inputText value="#{usuarioBean.usuario.email}" id="email" required="true" requiredMessage="O campo email é obrigatório." >
                                   <p:ajax update="email_valido" listener="#{usuarioBean.buscarEmail}"></p:ajax>
                           </p:inputText>
                                   <h:outputText value="#{usuarioBean.emailValido}" id="email_valido"></h:outputText>
                                   
                                   <p:outputLabel value="Senha" for="senha"/>
                                   <p:password  value="#{usuarioBean.usuario.senha}" feedback="true" id="senha" requiredMessage="Preencha o campo senha:" required="true"
                                           promptLabel="Preencha o campo Senha" weakLabel="Senha Fraca"  
                           goodLabel="Senha media" strongLabel=" Senha Forte"  validatorMessage="Sua senha deve ter no minimo 8 digitos!">
                           <f:validateLength minimum="8"></f:validateLength>
                           </p:password>  
                                   <h:outputText>&nbsp;</h:outputText>
                                   
                                   <p:outputLabel value="Confirmar Senha" for="confirmarSenha"/>
                                   <p:password value="#{usuarioBean.confirmarSenha}" id="confirmarSenha" requiredMessage="Preencha o campo Confirmação senha"
                                           required="true">
                                   </p:password>
                                   <h:outputText>&nbsp;</h:outputText>
                                   
                                   <p:commandButton value="Reset" type="reset" />  
                                   <p:commandButton value="Cadastrar" process="@form message_cadastrar"  update="@form message_cadastrar"
                                                   action="#{usuarioBean.cadastrarUsuario}"/>
                                   <h:outputText>&nbsp;</h:outputText>
                           </h:panelGrid>
                                                   
                     </p:panel>
                   </h:form>
           </div>
        </ui:define>    
        </ui:composition>
</h:body>
</html>